<template>
  <div class="uni-calendar-item__weeks-box"
       :class="{
         'uni-calendar-item--disable':weeks.disable,
         'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
         'uni-calendar-item--checked':(calendar.fullDate === weeks.fullDate && !weeks.isDay) ,
         'uni-calendar-item--before-checked':weeks.beforeMultiple,
         'uni-calendar-item--multiple': weeks.multiple,
         'uni-calendar-item--after-checked':weeks.afterMultiple,
       }"
       @click="choiceDate(weeks)"
       @contextmenu.prevent="rightMenu"
  >
    <div class="uni-calendar-item__weeks-box-item">
      <span v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></span>
      <span class="uni-calendar-item__weeks-box-span"
            :class="{
              'uni-calendar-item--isDay-span': weeks.isDay,
              'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
              'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
              'uni-calendar-item--before-checked':weeks.beforeMultiple,
              'uni-calendar-item--multiple': weeks.multiple,
              'uni-calendar-item--after-checked':weeks.afterMultiple,
              'uni-calendar-item--disable':weeks.disable,
              'uni-calendar-item--isNotWorkDay':!weeks.isDay && weeks.isWork
            }"
      >{{ weeks.date }}</span>
      <span v-if="!lunar&&!weeks.extraInfo && weeks.isDay"
            class="uni-calendar-item__weeks-lunar-span"
            :class="{
              'uni-calendar-item--isDay-span':weeks.isDay,
              'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
              'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
              'uni-calendar-item--before-checked':weeks.beforeMultiple,
              'uni-calendar-item--multiple': weeks.multiple,
              'uni-calendar-item--after-checked':weeks.afterMultiple,
            }"
      >{{ $t('DiyCalendar.today') }}</span>
      <span v-if="lunar&&!weeks.extraInfo"
            class="uni-calendar-item__weeks-lunar-span"
            :class="{
              'uni-calendar-item--isDay-span':weeks.isDay,
              'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
              'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
              'uni-calendar-item--before-checked':weeks.beforeMultiple,
              'uni-calendar-item--multiple': weeks.multiple,
              'uni-calendar-item--after-checked':weeks.afterMultiple,
              'uni-calendar-item--disable':weeks.disable,
            }"
      >{{ weeks.isDay ? todayText : (weeks.lunar.IDayCn === '初一'?weeks.lunar.IMonthCn:weeks.lunar.IDayCn) }}</span>
      <span v-if="weeks.extraInfo&&weeks.extraInfo.info"
            class="uni-calendar-item__weeks-lunar-span"
            :class="{
              'uni-calendar-item--extra':weeks.extraInfo.info,
              'uni-calendar-item--isDay-span':weeks.isDay,
              'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
              'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
              'uni-calendar-item--before-checked':weeks.beforeMultiple,
              'uni-calendar-item--multiple': weeks.multiple,
              'uni-calendar-item--after-checked':weeks.afterMultiple,
              'uni-calendar-item--disable':weeks.disable,
            }"
      >{{ weeks.extraInfo.info }}</span>
    </div>
  </div>
</template>

<script>
// import { initVueI18n } from '@dcloudio/uni-i18n'
// import i18nMessages from './i18n/index.js'
// const {	t	} = initVueI18n(i18nMessages)

export default {
  name: 'DiyCalendarItem',
  emits: ['change', 'rightClick'],
  props: {
    weeks: {
      type: Object,
      default() {
        return {}
      }
    },
    calendar: {
      type: Object,
      default: () => {
        return {}
      }
    },
    selected: {
      type: Array,
      default: () => {
        return []
      }
    },
    lunar: {
      type: Boolean,
      default: false
    }
  },
  // computed: {
  // 	todayText() {
  // 		return t("uni-calender.today")
  // 	},
  // },
  methods: {
    choiceDate(weeks) {
      this.$emit('change', weeks)
    },
    rightMenu(event) {
      this.$emit('rightClick', event)
    }
  }
}
</script>

<style lang="scss" scoped>
	$uni-font-size-base:14px;
	$uni-span-color:#333;
	$uni-font-size-sm:12px;
	$uni-color-error: #e43d33;
	$uni-opacity-disabled: 0.3;
	$uni-span-color-disable:#c0c0c0;
	$uni-primary: #2979ff !default;
	.uni-calendar-item__weeks-box {
		flex: 1;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.uni-calendar-item__weeks-box-span {
		font-size: $uni-font-size-base;
		color: $uni-span-color;
	}

	.uni-calendar-item__weeks-lunar-span {
		font-size: $uni-font-size-sm;
		color: $uni-span-color;
	}

	.uni-calendar-item__weeks-box-item {
		position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
		width: 100rpx;
		height: 100rpx;
	}

	.uni-calendar-item__weeks-box-circle {
		position: absolute;
		top: 5px;
		right: 5px;
		width: 8px;
		height: 8px;
		border-radius: 8px;
		background-color: $uni-color-error;

	}

	.uni-calendar-item--disable {
		background-color: rgba(249, 249, 249, $uni-opacity-disabled);
		color: $uni-span-color-disable;
	}

	.uni-calendar-item--isDay-span {
		color: $uni-primary;
	}

	.uni-calendar-item--isDay {
		background-color: $uni-primary;
		opacity: 0.8;
		color: #fff;
	}

	.uni-calendar-item--isNotWorkDay {
		color: red;
	}

	.uni-calendar-item--extra {
		color: $uni-color-error;
		opacity: 0.8;
	}

	.uni-calendar-item--checked {
		background-color: $uni-primary;
		color: #fff;
		opacity: 0.8;
	}

	.uni-calendar-item--multiple {
		background-color: $uni-primary;
		color: #fff;
		opacity: 0.8;
	}
	.uni-calendar-item--before-checked {
		background-color: #ff5a5f;
		color: #fff;
	}
	.uni-calendar-item--after-checked {
		background-color: #ff5a5f;
		color: #fff;
	}
</style>
